import Vue from 'vue'
import App from './App'
import router from './router'
import { WechatPlugin } from 'vux'
import { getUserInfo } from './utils/localstorage'

Vue.use(WechatPlugin)
Vue.config.productionTip = false

router.beforeEach((to, from, next) => {
  const userInfo = getUserInfo()
  if (!userInfo && to.path !== '/login' && to.path !== '/redirect') {
    router.push({path: '/login'})
  }
  return next()
})

/* eslint-disable no-new */
new Vue({
  el: '#app',
  router,
  render: h => h(App)
})
